package com.jack.thinking.thread.core._2;

public class MemberVarNotSynchronized {
	public static void main(String[] args) throws Exception {
		PrintString ps = new PrintString();
		Thread t = new Thread() {
			@Override
			public void run() {
				ps.printStringMethod();
			}
		};
		t.start();
		System.out.println("stop it");
		Thread.sleep(1000);
		ps.setContinuePrint(false);
	}
}


class PrintString{
	private boolean isContinuePrint = true;

	public boolean isContinuePrint() {
		return isContinuePrint;
	}

	public void setContinuePrint(boolean isContinuePrint) {
		this.isContinuePrint = isContinuePrint;
	}
	
	public void printStringMethod() {
		try {
			while(isContinuePrint == true) {
				System.out.println("run printStringMethod threadName=" + Thread.currentThread().getName());
				Thread.sleep(1000);
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}